import request from '@/utils/request'

/**
 *
 * @param {String} mobile 手机号
 * @param {String} code 验证码
 * @returns
 */
export const loginAPI = (mobile, code) => {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data: {
      mobile,
      code
    }
  })
}
// 发送验证码
/**
 *
 * @returns
 */
export const getCodeAPI = (mobile) => {
  return request({
    url: `/v1_0/sms/codes/${mobile}`
  })
}
// 请求用户自己的信息
export const getUserInfoAPI = () => {
  return request({
    url: '/v1_0/user'
  })
}
// 个人资料
/**
 *获取个人资料
 * @returns promise
 */
export const getUserProfileAPI = () => {
  return request({
    url: '/v1_0/user/profile'
  })
}
// 修改个人资料
/**
 *
 * @param {*} data {name ,gender,birthday}
 * @returns promise
 */
export const editUserProfileAPI = (data) => {
  return request({
    url: '/v1_0/user/profile',
    Method: 'PATCH',
    data
  })
}
/**
 * 上传头像
 * @param {*} file 图片的文件对象
 * @returns promise
 */

export const uploadPhoto = (file) => {
  const fm = new FormData()
  fm.append('photo', file)
  return request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data: fm
  })
}
